ORIG_NAME = "JWL_orig"
DATA_FILE = "detonation__.dat"
DATA_NAME = "PBX25IN"
DATA_EXT = ["dis", "eos", "exp", "fas", "geo"]

PATTERNS_P = {"dis": [" 0"],
                    "eos": [" 2"],
                    "exp": [" 0"],
                    "fas": [" 2"],
                    "geo": [" 3"]
                }
                
PATTERNS = {"dis": [" 0"],
                    "eos": [" 0 7 2 0 2 2 7 0 2 0",
                            " 0 0 2 7 0 0 0 2 0 7",
                            " 0 0 2 0 0 0 0 7 2 0",
                            " 7 2 0 2 7 2 2 0 2 0",
                            " 0 2 0 0 2 0 7 0 0 7",
                            " 0 0 7 0 2 0 0 2 2 0",
                            " 2 0 0 2 0 7 0 7 0 0",
                            " 0 7 2 0 0 0 0 0 2 2",
                            " 0 0 2 7 2 0 7 2 0 7",
                            " 7 2 0 0 0 2 0 0 7 0"],
                    "exp": [" 0 1 0 0 0 0 1 0 0 0",
                            " 0 0 0 1 0 0 0 0 0 1",
                            " 0 0 0 0 0 0 0 1 0 0",
                            " 1 0 0 0 1 0 0 0 0 0",
                            " 0 0 0 0 0 0 1 0 0 1",
                            " 0 0 1 0 0 0 0 0 0 0",
                            " 0 0 0 0 0 1 0 1 0 0",
                            " 0 1 0 0 0 0 0 0 0 0",
                            " 0 0 0 1 0 0 1 0 0 1",
                            " 1 0 0 0 0 0 0 0 1 0"],
                    "fas": [" 0 2 2 0 2 2 2 0 2 0",
                            " 0 0 2 2 0 0 0 2 0 2",
                            " 0 0 2 0 0 0 0 2 2 0",
                            " 2 2 0 2 2 2 2 0 2 0",
                            " 0 2 0 0 2 0 2 0 0 2",
                            " 0 0 2 0 2 0 0 2 2 0",
                            " 2 0 0 2 0 2 0 2 0 0",
                            " 0 2 2 0 0 0 0 0 2 2",
                            " 0 0 2 2 2 0 2 2 0 2",
                            " 2 2 0 0 0 2 0 0 2 0"],
                    "geo": [" 0 1 2 0 2 2 1 0 2 0",
                            " 0 0 2 1 0 0 0 2 0 1",
                            " 0 0 2 0 0 0 0 1 2 0",
                            " 1 2 0 2 1 2 2 0 2 0",
                            " 0 2 0 0 2 0 1 0 0 1",
                            " 0 0 1 0 2 0 0 2 2 0",
                            " 2 0 0 2 0 1 0 1 0 0",
                            " 0 1 2 0 0 0 0 0 2 2",
                            " 0 0 2 1 2 0 1 2 0 1",
                            " 1 2 0 0 0 2 0 0 1 0"]
                }

def data_generate(fname, h, w, w_p):
    ext = fname[-3:]
    ofile = open(fname, "w")
    
    wp = len(PATTERNS_P[ext])
    hp = len(PATTERNS_P[ext][0]) / 2
    
    iw = 0
    
    while iw < w_p:
        for i in range(h / hp):
            ofile.write(PATTERNS_P[ext][iw % wp])
        ofile.write(PATTERNS_P[ext][iw % wp][:2*(h % hp)])
        ofile.write("\n")
        iw = iw + 1
    
    wp = len(PATTERNS[ext])
    hp = len(PATTERNS[ext][0]) / 2
    
    iw = 0
    while iw < w - w_p:
        for i in range(h / hp):
            ofile.write(PATTERNS[ext][iw % wp])
        ofile.write(PATTERNS[ext][iw % wp][:2*(h % hp)])
        ofile.write("\n")
        iw = iw + 1
    
    ofile.close()

if __name__ == "__main__":
    print "Start JWL"
    for ext in DATA_EXT:
        #data_generate("JWL_test01/" + DATA_NAME + "." + ext, 200, 2000, 200)
        #data_generate("JWL_test02/" + DATA_NAME + "." + ext, 400, 4000, 200)
        data_generate("JWL_test03/" + DATA_NAME + "." + ext, 100, 1000, 100)
    print "End JWL"
